<template>
  <div class="box">
    <van-nav-bar
      title="个人中心"
      left-text="返回"
      right-text="退出"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
    <span>个人中心</span>
    <div class="list">
      <RouterLink to="/address">
        <van-cell is-link title="地址管理" />
      </RouterLink>
      <RouterLink to="/order">
        <van-cell is-link title="订单中心" />
      </RouterLink>
    </div>
  </div>
</template>

<script>
import { showToast } from "vant";
export default {
  setup() {
    return {};
  },
  methods: {
    onClickLeft() {
      history.back();
    },
    //退出登录
    onClickRight() {
      //删除token'
      //删除仓库数据
      //跳转登录页
      localStorage.removeItem("token");
      this.$store.commit("setUserInfo","");
      this.$router.push("login");
      showToast("退出登录");  
    },
  },
};
</script>

<style lang="scss" scoped>
.box {
  background-color: #f5f5f5;
  height: 100vh;
  span {
    font-size: 14px;
    margin: 10px;
  }
}
.list {
  margin: 10px 10px;
}
</style>
